package cn.hdu.liang.pipe;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

public class Run {
    public static void main(String[] args) {
        try {
            WriteData write = new WriteData();
            ReadData read = new ReadData();
            PipedInputStream input = new PipedInputStream();
            PipedOutputStream out = new PipedOutputStream();

            //input.connect(out);
            out.connect(input);

            ThreadRead tr = new ThreadRead(read, input);
            tr.start();

            Thread.sleep(1000);

            ThreadWrite tw = new ThreadWrite(write, out);
            tw.start();

        } catch(IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
